package com.hxzy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hxzy.common.util.WaimaiThreadLocal;
import com.hxzy.dto.MerchandiserSearchDTO;
import com.hxzy.entity.Merchandiser;
import com.hxzy.mapper.MerchandiserMapper;
import com.hxzy.service.MerchandiserService;
import com.hxzy.vo.ReportVO;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商家业务逻辑实现
 * @author Administrator
 */
@Service
public class MerchandiserServiceImpl extends ServiceImpl<MerchandiserMapper, Merchandiser> implements MerchandiserService {


    /**
     * 查询
     * @param merchandiserSearchDTO
     * @return
     */
    @Override
    public List<Merchandiser> search(MerchandiserSearchDTO merchandiserSearchDTO) {
        return super.getBaseMapper().search(merchandiserSearchDTO);
    }

    @Override
    public Merchandiser selectByPrimaryKey(Long id) {
        return super.getBaseMapper().selectByPrimaryKey(id);
    }

    @Override
    public long notApprovedNum() {
        if(WaimaiThreadLocal.isSuperMan()){
            QueryWrapper<Merchandiser> queryWrapper=new QueryWrapper<>();
            queryWrapper.eq("status",1);
           return  this.count(queryWrapper);
        }else{
            return 0;
        }
    }

    @Override
    public List<ReportVO> monthlyNumers() {
        return this.baseMapper.monthlyNumers();
    }
}
